#ifndef PLAYER_H
#define PLAYER_H

#include <QWidget>

#include <physics/pship.h>

class Player : public QObject
{
    Q_OBJECT
public:
    explicit Player(PWorld *world, PVector startPos, double startAngle, QString name, QObject *parent = 0, bool createShip = true);

    QColor getColor() const;
    PShip *getShip();
    QString getName() const;

    void setColor(QColor color);

    bool isAlive() const;

    int getLives() const;
    PVector getStartPos() const;
    double getStartAngle() const;
    void shipDied();

    virtual void serialize(QDomDocument *doc, QDomElement *e) const;

    static Player *deserialize(QDomNode e, PWorld *world);

    virtual QString getType() const;

signals:

public slots:
    void pressAccelerate();
    void pressFire();
    void pressLeft();
    void pressRight();
    void releaseAccelerate();
    void releaseFire();
    void releaseLeft();
    void releaseRight();

protected:

private:
    PWorld *myWorld;
    QString myName;
    PVector myStartPos;
    double myStartAngle;
    int myLives;
    QColor myColor;

    bool alive;

    static const int MAX_LIVES = 10;
};

#endif // PLAYER_H
